"""
FastMCP server creation and configuration
"""

from fastmcp import FastMCP
from config import settings

# Import all MCP components
from .tools import register_tools
from .resources import register_resources
from .prompts import register_prompts
from .proxies import ProxyRegistry


async def create_mcp_server() -> FastMCP:
    """
    Create and configure the FastMCP server with all tools, resources, and prompts
    """
    # Create the FastMCP server instance
    mcp = FastMCP(
        name=settings.MCP_NAME,
        instructions="""
        This is a FastMCP demonstration server that provides various tools, resources, and prompts.
        
        Available capabilities:
        - Tools: Mathematical calculations, text processing, file operations, weather data
        - Resources: Configuration data, user information, system status
        - Prompts: Data analysis, code generation, writing assistance
        - Proxies: Dynamic proxy management for external MCP servers
        
        Use the list_tools, list_resources, and list_prompts commands to see all available functionality.
        """,
    )

    # Register all components
    register_tools(mcp)
    register_resources(mcp)
    register_prompts(mcp)

    # Initialize and register proxies
    proxy_registry = ProxyRegistry(mcp)
    await proxy_registry.register()

    return mcp, proxy_registry


# For standalone MCP server usage
if __name__ == "__main__":
    import asyncio

    async def main():
        server, proxy_registry = await create_mcp_server()
        server.run()

    asyncio.run(main())
